package pl.edu.pw.polygen.modeler.server.xml;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class Vertex {
	
	private Integer id;
	private Double x;
	private Double y;
	private String type;
	private Integer boundary = 0;
	private Double value = 0.1;

	@XmlElementWrapper(name = "edges")
	@XmlElement(name="edge")
	private List<Edge> edges = new ArrayList<Edge>();
	
	public Integer getId() {
		return id;
	}
	
	public void setId(Integer id) {
		this.id = id;
	}
	
	public Double getX() {
		return x;
	}
	
	public void setX(Double x) {
		this.x = x;
	}
	
	public Double getY() {
		return y;
	}
	
	public void setY(Double y) {
		this.y = y;
	}
	
	public String getType() {
		return type;
	}
	
	public void setType(String type) {
		this.type = type;
	}
	
	public Integer getBoundary() {
		return boundary;
	}

	public void setBoundary(Integer boundary) {
		this.boundary = boundary;
	}

	public List<Edge> getEdges() {
		return edges;
	}

	public void setEdges(List<Edge> edges) {
		this.edges = edges;
	}
	
	public void addEdge(Edge edge){
		this.edges.add(edge);
	}
	
	public Double getValue() {
		return value;
	}

	public void setValue(Double value) {
		this.value = value;
	}

	@Override
	public String toString(){
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.append("id: " + id + "\n");
		stringBuilder.append("x: " + x + "\n");
		stringBuilder.append("y: " + y+ "\n");
		stringBuilder.append("type: " + type+ "\n");
		stringBuilder.append("edges: " + edges.size()+ "\n");
		for(Edge e : edges){
			stringBuilder.append(e.toString());
		}
		return stringBuilder.toString();
	}
	
}
